define(function(require,exports,module){
	
	//var tpl = require('../../tpl/member/my_wineCard.tpl');//载入tpl模板
	
	
	var card=["wine","palm","cabinet"];
	var cardIds = [];
	
	getMyWineCard();
	
	function getMyWineCard(){
		cardIds = [];
		$.ajax({
			url:'/member/usercard/list.html',
			success:function(data){
				for(var i=0;i<card.length;i++){
					if(data[card[i]+'_wind_card']!=undefined){
						$("."+card[i]+"Card").removeClass("unget"+card[i]+"Card");
						cardIds.push(data[card[i]+'_wind_card']);
					}else{
						$("."+card[i]+"Card").addClass("unget"+card[i]+"Card");
					}
				}
			}
		})
	}
	
	$(".my_wineCardBtn a").click(function(){
		
		if(cardIds.length==3){
			$.ajax({
				url:"/member/usercard/exchange/wine.html",
				data:{cardIds:cardIds.join(",")},
				success:function(data){
					if(data.result){
						getMyWineCard();
						windCardTyj();
					}else{
						layer.alert(data.msg);
					}
				}
			});
		}else{
			layer.alert("请分别集齐酒、掌、柜三张卡进行兑换！");
		}
	});
	
	function windCardTyj(){
		var htmls = [];
		htmls.push('<div class="myWindCardLayer">');
		htmls.push('<div class="myWineCardTyj"><span>恭喜您成功兑换9999元体验金</span><img alt="体验金" src="/themes/theme_default/images/jzg_tyj.png" />');
		htmls.push('<a class="sureBtn">确定</a><div class="windCardcloseBtn"></div></div></div>');
		
		$("body").append(htmls.join(""));
		setTimeout(function(){
			$(".myWineCardTyj").addClass("myWineCardGetout");
		},10);
		$(".windCardcloseBtn,.sureBtn").click(function(){
			$(".myWindCardLayer").remove();
		})
	}
});